index.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { NextApiRequest, NextApiResponse } from 'next'
  2. import apiWrapper from '@/lib/api/apiWrapper'
  3. export default (req: NextApiRequest, res: NextApiResponse) => apiWrapper(req, res, handler)
  4. async function handler(req: NextApiRequest, res: NextApiResponse) {
  5. const { method } = req
  6. switch (method) {
  7. case 'GET':
  8. return handleGetAll(req, res)
  9. case 'PATCH':
  10. return handlePatch(req, res)
  11. default:
  12. res.setHeader('Allow', ['GET'])
  13. res.status(405).json({ data: null, error: { message: `Method ${method} Not Allowed` } })
  14. }
  15. }
  16. const handleGetAll = async (_req: NextApiRequest, res: NextApiResponse) => {
  17. // Platform specific endpoint
  18. return res.status(200).json({
  19. db_anon_role: 'anon',
  20. db_extra_search_path: 'public',
  21. db_schema: 'public, storage',
  22. jwt_secret:
  23. process.env.AUTH_JWT_SECRET ?? 'super-secret-jwt-token-with-at-least-32-characters-long',
  24. max_rows: 100,
  25. role_claim_key: '.role',
  26. })
  27. }
  28. const handlePatch = async (_req: NextApiRequest, res: NextApiResponse) => {
  29. // Platform specific endpoint
  30. return res.status(200).json({})
  31. }